package com.qf.dao;

import com.qf.entity.Wife;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

/**
 * 2019/9/29
 * Administrator
 * springdata0928
 * 面向对象面向君  不负代码不负卿
 */
public interface WifeDao extends JpaRepository<Wife,Integer> {
    //查询妻子的信息(包含丈夫的信息)
    //public Wife findByWifeid(int wid);
   // @Query("from Wife where wifeId=?1")
    @Query(nativeQuery = true,value = "select * from wife where wifeid=?")
    public Wife selectwifebyid(int wifeid);
    //通过丈夫的名字查询妻子的信息
    //public Wife findByHusband_Husname(String name);
    //@Query("from Wife  w,Husband h  where w.husband.husid=h.husid and h.husname=?1")
    //@Query("from Wife  w,Husband h  where w.husband.husid=h.husid and h.husname=:abc")
    @Query(nativeQuery = true,value = "select *from Wife  w,Husband h  where w.hid=h.husid and h.husname=:abc")
    public Wife selectwifebyhusname(@Param("abc") String name);
    //根据用户id更新妻子信息
    @Modifying
    @Query("update Wife set wifename=?1 where wifeid=?2")
    public int updateWife(String name,int wid);

}
